home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-04-30 | 7.1 KB | 313 lines | [TEXT/MPCC] |
- /*
- File: MacApplication.c
-
- Contains: Digitizer Shell specific functions concerning the application shell.
-
- Written by: DTS
-
- Copyright: © 1994-1995 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <1> 4/25/95 khs first file
-
- */
-
-
- // INCLUDES
- #include "MacApplication.h"
- #include "MacFramework.h"
- #include "AppConfiguration.h"
- #include "DTSQTUtilities.h"
-
- // Header file for the specific test functions.
- #include "TestFunctions.h"
-
- // GLOBALS
- long gMaxMilliSecToUse = 0L;
-
- // These are our global SG settings, if needed we need to export these using get/set functions
- // as these are internal to this file (.c).
- SeqGrabComponent gSG = NULL;
- WindowPtr gCaptureWindow = NULL;
- SGChannel gVideoChannel = NULL;
- SGChannel gAudioChannel = NULL;
-
-
-
- // FUNCTIONS
- // ______________________________________________________________________
- void DoIdle(WindowRef theWindow)
- {
- GrafPtr aSavedPort;
-
- GetPort(&aSavedPort);
- SetPort(theWindow);
-
- // Update the SG port assuming it's in use.
- if(gSG != NULL)
- SGIdle(gSG);
-
- // @@@INSERT ANY IDLE BASED FUNCTIONALITY HERE
-
- SetPort(aSavedPort);
- }
-
-
- // ______________________________________________________________________
- void DoUpdateWindow(WindowRef theWindow, Rect *theRefrehArea)
- {
- GrafPtr aSavedPort;
-
- GetPort(&aSavedPort);
- SetPort(theWindow);
-
- BeginUpdate(theWindow);
-
- if(gSG != NULL)
- SGUpdate(gSG, NULL);
-
- // @@@INSERT WINDOW SPECIFIC DRAWING FUNCTIONALITY HERE
-
- EndUpdate(theWindow);
- SetPort(aSavedPort);
- }
-
-
-
- // ______________________________________________________________________
- void DoCloseWindow(WindowRef theWindow)
- {
- OSErr anErr = noErr;
-
- gCaptureWindow = NULL;
-
- // Clean up the channels (CloseComponent will handle that).
- anErr = CloseComponent(gSG); DebugAssert(anErr != noErr);
- gSG = NULL; gVideoChannel = NULL; gAudioChannel = NULL;
- }
-
-
- // ______________________________________________________________________
- void DoDragWindow(WindowRef theWindow, EventRecord *theEvent)
- {
- GrafPtr aSavedPort;
- ICMAlignmentProcRecord alignProc;
-
- GetPort(&aSavedPort);
- SetPort(theWindow);
-
- if(gSG != NULL)
- {
- SGPause(gSG, TRUE);
- SGGetAlignmentProc(gSG, &alignProc);
-
- DragAlignedWindow(theWindow, theEvent->where, &qd.screenBits.bounds, NULL, &alignProc);
- SGPause(gSG, FALSE);
- }
- // @@@INSERT WINDOW DRAGGING SPECIFIC FUNCTIONALITY HERE
-
- SetPort(aSavedPort);
- }
-
- // ______________________________________________________________________
- void HandleContentClick(WindowRef theWindow, EventRecord *theEvent)
- {
- GrafPtr aSavedPort;
-
- GetPort(&aSavedPort);
- SetPort(theWindow);
-
- // @@@INSERT APPLICATION SPECIFIC CONTENT CLICKING FUNCTIONALITY HERE
-
- SetPort(aSavedPort);
- }
-
-
-
- // ______________________________________________________________________
- WindowRef CreateMovieWindow(Rect *theRect, Str255 theTitle)
- {
- WindowPtr aWindow = NULL;
- Rect devRect;
-
- GetBestDeviceRect(NULL, &devRect);
-
- OffsetRect(theRect, devRect.left + 20, devRect.top + 20);
- aWindow = NewCWindow( NULL, theRect, theTitle, TRUE, noGrowDocProc, (WindowPtr)-1,
- TRUE, 0);
- return aWindow;
- }
-
- // ______________________________________________________________________
- void HandleApplicationMenu(short theMenuID, short theMenuItem)
- {
- // HANDLE ANY ADDITIONAL MENU ENTRIES HERE
- switch(theMenuID)
- {
- // Test menus.
- case mTesting:
- switch(theMenuItem)
- {
- case iTest1:
- {
- ShowVDIGInfo();
- break;
- }
-
- case iTest2:
- {
- SetMyVideoChannelSettings();
- break;
- }
-
- case iTest3:
- {
- SetMyAudioChannelSettings();
- break;
- }
- }
- break;
-
- // Capture Size Menus.
- case mCaptureSize:
- {
- switch(theMenuItem)
- {
- case iSizeNormal:
- {
- if( QTUChangeSGWindowSize( GetDefaultSGInstance(), GetDefaultVideoChannel() , gCaptureWindow, 320L, 240L) != noErr)
- SysBeep(kDefaultSysBeep);
- break;
- }
-
- case iSizeSmall:
- {
- if ( QTUChangeSGWindowSize( GetDefaultSGInstance(), GetDefaultVideoChannel() , gCaptureWindow,160L, 120L) != noErr)
- SysBeep(kDefaultSysBeep);
- break;
- }
-
- case iSizeBig:
- {
- if ( QTUChangeSGWindowSize( GetDefaultSGInstance(), GetDefaultVideoChannel() , gCaptureWindow, 640L, 480L) != noErr)
- SysBeep(kDefaultSysBeep);
- break;
- }
- }
- break;
- }
-
- // End testing menus
- }
- }
-
-
- // ______________________________________________________________________
- void AdjustApplicationMenus(void)
- {
-
- // For the time being always dim the edit entries (maybe later if needed enable these)
- DisableItem(GetMHandle(mEdit), iUndo);
- DisableItem(GetMHandle(mEdit), iCut);
- DisableItem(GetMHandle(mEdit), iCopy);
- DisableItem(GetMHandle(mEdit), iPaste);
- DisableItem(GetMHandle(mEdit), iClear);
- DisableItem(GetMHandle(mEdit), iSelectAll);
-
- // Test if we have a valid capture window open, if true, then enable the right menus, otherwise
- // disable them.
- if(gCaptureWindow != NULL)
- {
- DisableItem(GetMHandle(mFile), iNew);
- EnableItem(GetMHandle(mFile), iClose);
-
- EnableItem(GetMHandle(mTesting), iTest1);
-
- EnableItem(GetMHandle(mTesting), iTest2);
- EnableItem(GetMHandle(mTesting), iTest3);
-
- EnableItem(GetMHandle(mCaptureSize), iSizeNormal);
- EnableItem(GetMHandle(mCaptureSize), iSizeSmall);
- EnableItem(GetMHandle(mCaptureSize), iSizeBig);
- }
- else
- {
- EnableItem(GetMHandle(mFile), iNew);
- DisableItem(GetMHandle(mFile), iClose);
-
- DisableItem(GetMHandle(mTesting), iTest1);
- DisableItem(GetMHandle(mTesting), iTest2);
- DisableItem(GetMHandle(mTesting), iTest3);
-
- DisableItem(GetMHandle(mCaptureSize), iSizeNormal);
- DisableItem(GetMHandle(mCaptureSize), iSizeSmall);
- DisableItem(GetMHandle(mCaptureSize), iSizeBig);
- }
- }
-
-
- // ______________________________________________________________________
- void CreateSGEnviroment(void)
- {
- OSErr anErr = noErr;
- WindowPtr aWin = NULL;
- Rect defRect = {20, 20, 260, 340};
-
- if(gSG != NULL || gCaptureWindow != NULL) // already in use
- return;
-
- gCaptureWindow = CreateMovieWindow(&defRect, "\pSG Grabber Window");
- DebugAssert(gCaptureWindow != NULL);
-
- gSG = QTUCreateSequenceGrabber(gCaptureWindow); DebugAssert(sg != NULL);
- if(gSG == NULL)
- {
- printf("ERROR: Problem opening the default Sequence Grabber component.\n");
- goto Closure;
- }
-
- anErr = QTUCreateSGGrabChannels(gSG, &gCaptureWindow->portRect, seqGrabPlayDuringRecord + seqGrabRecord,
- &gVideoChannel, &gAudioChannel); DebugAssert(anErr == noErr); DebugAssert(anErr != noErr);
- if(anErr != noErr)
- {
- printf("ERROR: Problems creating the Video and Audio SG Channels: %ld.\n", anErr);
- goto Closure;
- }
-
- anErr = SGStartPreview(gSG); DebugAssert(anErr == noErr);
- if(anErr != noErr)
- {
- printf("ERROR: Problems starting the SG Preview: %ld.\n", anErr);
- goto Closure;
- }
- else
- printf("STATUS: Opened Default SG component, created channels (audio, sound), started Preview.\n");
-
- Closure:
- return;
- }
-
-
-
- // ______________________________________________________________________
- SeqGrabComponent GetDefaultSGInstance(void)
- {
- return gSG;
- }
-
-
- SGChannel GetDefaultVideoChannel(void)
- {
- return gVideoChannel;
- }
-
-
- SGChannel GetDefaultAudioChannel(void)
- {
- return gAudioChannel;
- }
-
-
-
-